﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAO;
using DTO;

namespace BUS
{
    public class DocSequenceBUS
    {
        DocSequenceDAO docSeqDAO = new DocSequenceDAO();

        /// <summary>
        /// Get DocSequence By Name of DocSequence
        /// </summary>
        /// <param name="name">Name of DocSequence</param>
        /// <returns>DocSequenceDTO</returns>
        public DocSequenceDTO GetDocSequenceByName(String name)
        {
            return docSeqDAO.GetDocSequenceByName(name);
        }

        public bool CheckDocSequenceExists(string code)
        {
            return docSeqDAO.CheckDocSequenceExists(code);
        }

        public bool UpdateNextDocSequence(string name)
        {
            return docSeqDAO.UpdateNextDocSequence(name);
        }

        public bool UpdateDocSequence(DocSequenceDTO doc)
        {
            return docSeqDAO.UpdateDocSequence(doc);
        }

        public bool UpdateDocSequence(List<DocSequenceDTO> listDocSeq)
        {
            try
            {
                bool isSucces = true;
                foreach (DocSequenceDTO doc in listDocSeq)
                {
                    isSucces = docSeqDAO.UpdateDocSequence(doc);
                }
                return isSucces;
            }
            catch
            {
                return false;
            }
        }

        public string GetNextDocSequenceNumber(string name)
        {
            return docSeqDAO.GetNextDocSequenceNumber(name);
        }

        public List<DocSequenceDTO> GetListDocSequence()
        {
            return docSeqDAO.GetListDocSequence();
        }
    }
}
